﻿<ResourceDictionary 
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >

  <ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="../Brushes.xaml"/>
  </ResourceDictionary.MergedDictionaries>

  <ControlTemplate x:Key="TextBoxTemplate" TargetType="{x:Type TextBox}">
    <ControlTemplate.Resources>
      <Storyboard x:Key="HoverOn">
        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="HoverBorder" Storyboard.TargetProperty="(UIElement.Opacity)">
          <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="0.5" />
        </DoubleAnimationUsingKeyFrames>
      </Storyboard>
      <Storyboard x:Key="HoverOff">
        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="HoverBorder" Storyboard.TargetProperty="(UIElement.Opacity)">
          <SplineDoubleKeyFrame KeyTime="00:00:00.4000000" Value="0" />
        </DoubleAnimationUsingKeyFrames>
      </Storyboard>
      <Storyboard x:Key="FocusedOn">
        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Opacity">
          <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1" />
        </DoubleAnimationUsingKeyFrames>
      </Storyboard>
      <Storyboard x:Key="FocusedOff">
        <DoubleAnimationUsingKeyFrames Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Opacity">
          <SplineDoubleKeyFrame KeyTime="00:00:00.4000000" Value="0" />
        </DoubleAnimationUsingKeyFrames>
      </Storyboard>
    </ControlTemplate.Resources>
    <Grid>
      <Border x:Name="Border" Opacity="1" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2,2,2,2" Background="{TemplateBinding Background}">
        <Grid>
          <Border BorderThickness="1">
            <ScrollViewer Margin="0" x:Name="PART_ContentHost" Style="{DynamicResource NuclearScrollViewer}" />
          </Border>
        </Grid>
      </Border>
      <Border x:Name="HoverBorder" IsHitTestVisible="False" Opacity="0" BorderBrush="{StaticResource GlyphBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2,2,2,2" />
      <Border x:Name="FocusVisualElement" IsHitTestVisible="False" Opacity="0" BorderBrush="{StaticResource HoverShineBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2,2,2,2" />

    </Grid>
    <ControlTemplate.Triggers>
      <Trigger Property="IsFocused" Value="True">
        <Trigger.ExitActions>
          <BeginStoryboard Storyboard="{StaticResource FocusedOff}" x:Name="FocusedOff_BeginStoryboard" />
        </Trigger.ExitActions>
        <Trigger.EnterActions>
          <BeginStoryboard Storyboard="{StaticResource FocusedOn}" x:Name="FocusedOn_BeginStoryboard" />
        </Trigger.EnterActions>

      </Trigger>
      <MultiTrigger>
        <MultiTrigger.ExitActions>
          <BeginStoryboard Storyboard="{StaticResource HoverOff}" x:Name="HoverOff_BeginStoryboard" />
        </MultiTrigger.ExitActions>
        <MultiTrigger.EnterActions>
          <BeginStoryboard Storyboard="{StaticResource HoverOn}" />
        </MultiTrigger.EnterActions>
        <MultiTrigger.Conditions>
          <Condition Property="IsMouseOver" Value="True" />
          <Condition Property="IsFocused" Value="False" />
        </MultiTrigger.Conditions>

      </MultiTrigger>
      <Trigger Property="IsEnabled" Value="False">
        <Setter Property="Background" TargetName="Border" Value="{DynamicResource DisabledBackgroundBrush}" />
        <Setter Property="BorderBrush" TargetName="Border" Value="{DynamicResource DisabledBorderBrush}" />
        <Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}" />
      </Trigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>

  <Style TargetType="{x:Type TextBox}">
    <Setter Property="KeyboardNavigation.TabNavigation" Value="None" />
    <!-- Setter Property="FocusVisualStyle" Value="{x:Null}" / -->
    <Setter Property="AllowDrop" Value="true" />
    <Setter Property="Template" Value="{DynamicResource TextBoxTemplate}" />
    <Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
    <Setter Property="Background" Value="{DynamicResource ControlBackgroundBrush}"/>
    <Setter Property="BorderBrush" Value="#FF000000"/>
    <Setter Property="BorderThickness" Value="1" />

    <Setter Property="SelectionBrush" Value="{StaticResource SelectionBrush}" />
    <Setter Property="SelectionOpacity" Value="0.75" />
    <Setter Property="CaretBrush" Value="{StaticResource TextBrush}" />
    <Setter Property="Background" Value="{StaticResource ControlBackgroundBrush}" />
    <Setter Property="Foreground" Value="{StaticResource TextBrush}" />
    <Setter Property="ToolTipService.ShowOnDisabled" Value="True" />
  </Style>

  <Style TargetType="{x:Type PasswordBox}">
    <Setter Property="KeyboardNavigation.TabNavigation" Value="None" />
    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
    <Setter Property="AllowDrop" Value="true" />

    <Setter Property="SelectionBrush" Value="{StaticResource SelectionBrush}" />
    <Setter Property="SelectionOpacity" Value="0.75" />
    <Setter Property="CaretBrush" Value="{StaticResource TextBrush}" />
    <Setter Property="Background" Value="{StaticResource ControlBackgroundBrush}" />
    <Setter Property="Foreground" Value="{StaticResource TextBrush}" />

    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type PasswordBox}">
          <ControlTemplate.Resources>
            <Storyboard x:Key="HoverOn">
              <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="HoverBorder" Storyboard.TargetProperty="(UIElement.Opacity)">
                <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="0.5" />
              </DoubleAnimationUsingKeyFrames>
            </Storyboard>
            <Storyboard x:Key="HoverOff">
              <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="HoverBorder" Storyboard.TargetProperty="(UIElement.Opacity)">
                <SplineDoubleKeyFrame KeyTime="00:00:00.4000000" Value="0" />
              </DoubleAnimationUsingKeyFrames>
            </Storyboard>
            <Storyboard x:Key="FocusedOn">
              <DoubleAnimationUsingKeyFrames Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Opacity">
                <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1" />
              </DoubleAnimationUsingKeyFrames>
            </Storyboard>
            <Storyboard x:Key="FocusedOff">
              <DoubleAnimationUsingKeyFrames Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Opacity">
                <SplineDoubleKeyFrame KeyTime="00:00:00.4000000" Value="0" />
              </DoubleAnimationUsingKeyFrames>
            </Storyboard>
          </ControlTemplate.Resources>
          <Grid>
            <Border x:Name="Border" Opacity="1" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2,2,2,2" Background="{TemplateBinding Background}">
              <Grid>
                <Border BorderThickness="1">
                  <ScrollViewer Margin="0" x:Name="PART_ContentHost" Style="{DynamicResource NuclearScrollViewer}" />
                </Border>
              </Grid>
            </Border>
            <Border x:Name="HoverBorder" IsHitTestVisible="False" Opacity="0" BorderBrush="{StaticResource GlyphBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2,2,2,2" />
            <Border x:Name="FocusVisualElement" IsHitTestVisible="False" Opacity="0" BorderBrush="{StaticResource HoverShineBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2,2,2,2" />

          </Grid>
          <ControlTemplate.Triggers>
            <Trigger Property="IsFocused" Value="True">
              <Trigger.ExitActions>
                <BeginStoryboard Storyboard="{StaticResource FocusedOff}" x:Name="FocusedOff_BeginStoryboard"/>
              </Trigger.ExitActions>
              <Trigger.EnterActions>
                <BeginStoryboard Storyboard="{StaticResource FocusedOn}" x:Name="FocusedOn_BeginStoryboard"/>
              </Trigger.EnterActions>

            </Trigger>
            <MultiTrigger>
              <MultiTrigger.ExitActions>
                <BeginStoryboard Storyboard="{StaticResource HoverOff}" x:Name="HoverOff_BeginStoryboard"/>
              </MultiTrigger.ExitActions>
              <MultiTrigger.EnterActions>
                <BeginStoryboard Storyboard="{StaticResource HoverOn}"/>
              </MultiTrigger.EnterActions>
              <MultiTrigger.Conditions>
                <Condition Property="IsMouseOver" Value="True" />
                <Condition Property="IsFocused" Value="False" />
              </MultiTrigger.Conditions>

            </MultiTrigger>
            <Trigger Property="IsEnabled" Value="False">
              <Setter Property="Background" TargetName="Border" Value="{DynamicResource DisabledBackgroundBrush}"/>
              <Setter Property="BorderBrush" TargetName="Border" Value="{DynamicResource DisabledBorderBrush}"/>
              <Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}" />
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
    <Setter Property="Background" Value="{DynamicResource ControlBackgroundBrush}"/>
    <Setter Property="BorderBrush" Value="#FF000000"/>
  </Style>

  <Style TargetType="{x:Type RichTextBox}">
    <Setter Property="KeyboardNavigation.TabNavigation" Value="None" />
    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
    <Setter Property="AllowDrop" Value="true" />

    <Setter Property="SelectionBrush" Value="{StaticResource SelectionBrush}" />
    <Setter Property="SelectionOpacity" Value="0.75" />
    <Setter Property="CaretBrush" Value="{StaticResource TextBrush}" />
    <Setter Property="Background" Value="{StaticResource ControlBackgroundBrush}" />
    <Setter Property="Foreground" Value="{StaticResource TextBrush}" />

    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type RichTextBox}">
          <ControlTemplate.Resources>
            <Storyboard x:Key="HoverOn">
              <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="HoverBorder" Storyboard.TargetProperty="(UIElement.Opacity)">
                <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="0.5" />
              </DoubleAnimationUsingKeyFrames>
            </Storyboard>
            <Storyboard x:Key="HoverOff">
              <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="HoverBorder" Storyboard.TargetProperty="(UIElement.Opacity)">
                <SplineDoubleKeyFrame KeyTime="00:00:00.4000000" Value="0" />
              </DoubleAnimationUsingKeyFrames>
            </Storyboard>
            <Storyboard x:Key="FocusedOn">
              <DoubleAnimationUsingKeyFrames Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Opacity">
                <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1" />
              </DoubleAnimationUsingKeyFrames>
            </Storyboard>
            <Storyboard x:Key="FocusedOff">
              <DoubleAnimationUsingKeyFrames Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Opacity">
                <SplineDoubleKeyFrame KeyTime="00:00:00.4000000" Value="0" />
              </DoubleAnimationUsingKeyFrames>
            </Storyboard>
          </ControlTemplate.Resources>
          <Grid>
            <Border x:Name="Border" Opacity="1" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2,2,2,2" Background="{TemplateBinding Background}">
              <Grid>
                <Border BorderThickness="1">
                  <ScrollViewer Margin="0" x:Name="PART_ContentHost" Style="{DynamicResource NuclearScrollViewer}" />
                </Border>
              </Grid>
            </Border>
            <Border x:Name="HoverBorder" IsHitTestVisible="False" Opacity="0" BorderBrush="{StaticResource GlyphBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2,2,2,2" />
            <Border x:Name="FocusVisualElement" IsHitTestVisible="False" Opacity="0" BorderBrush="{StaticResource HoverShineBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2,2,2,2" />
          </Grid>
          <ControlTemplate.Triggers>
            <Trigger Property="IsFocused" Value="True">
              <Trigger.ExitActions>
                <BeginStoryboard Storyboard="{StaticResource FocusedOff}" x:Name="FocusedOff_BeginStoryboard"/>
              </Trigger.ExitActions>
              <Trigger.EnterActions>
                <BeginStoryboard Storyboard="{StaticResource FocusedOn}" x:Name="FocusedOn_BeginStoryboard"/>
              </Trigger.EnterActions>

            </Trigger>
            <MultiTrigger>
              <MultiTrigger.ExitActions>
                <BeginStoryboard Storyboard="{StaticResource HoverOff}" x:Name="HoverOff_BeginStoryboard"/>
              </MultiTrigger.ExitActions>
              <MultiTrigger.EnterActions>
                <BeginStoryboard Storyboard="{StaticResource HoverOn}"/>
              </MultiTrigger.EnterActions>
              <MultiTrigger.Conditions>
                <Condition Property="IsMouseOver" Value="True" />
                <Condition Property="IsFocused" Value="False" />
              </MultiTrigger.Conditions>

            </MultiTrigger>
            <Trigger Property="IsEnabled" Value="False">
              <Setter Property="Background" TargetName="Border" Value="{DynamicResource DisabledBackgroundBrush}"/>
              <Setter Property="BorderBrush" TargetName="Border" Value="{DynamicResource DisabledBorderBrush}"/>
              <Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}" />
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
    <Setter Property="Background" Value="{DynamicResource ControlBackgroundBrush}"/>
    <Setter Property="BorderBrush" Value="#FF000000"/>
  </Style>

</ResourceDictionary>
